package com.rainng.coursesystem.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;

@TableName("rc_homework")
@Data
public class HomeworkEntity {
    public static final String ID = "id";
    public static final String TITLE = "title";
    public static final String DESCRIPTION = "description";
    public static final String COURSE_ID = "course_id";
    public static final String DEADLINE = "deadline";
    public static final String STATUS = "status";
    public static final String CREATE_TIME = "create_time";
    public static final String PATH = "path";

    @NotNull
    @TableId(value = ID, type = IdType.AUTO)
    private Integer id;

    @NotBlank(message = "作业标题不能为空")
    @Length(max = 255, message = "作业标题长度不能超过255个字符")
    @TableField(TITLE)
    private String title;

    @TableField(DESCRIPTION)
    private String description;

    @NotNull(message = "课程ID不能为空")
    @TableField(COURSE_ID)
    private Integer courseId;

    @NotNull(message = "截止时间不能为空")
    @TableField(DEADLINE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime deadline;

    @NotBlank(message = "作业状态不能为空")
    @Length(max = 20, message = "作业状态长度不能超过20个字符")
    @TableField(STATUS)
    private String status;

    @NotNull(message = "创建时间不能为空")
    @TableField(CREATE_TIME)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime createTime;

    @TableField(PATH)
    private String path;

}    